home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / utility / cron16.zip / CRON.DOC < prev    next >
Text File  |  1991-01-20  |  63KB  |  1,986 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.                                    CRON User's Guide
  27.  
  28.  
  29.                                Manual Revision 01-20-91
  30.                                    CRON Version 1.6
  31.  
  32.                                      Shareware by
  33.                                      Tron Hvaring
  34.                                       PO Box 371
  35.                                      N-8501 Narvik
  36.                                         Norway
  37.  
  38.                                   Phone: +47 82 44145
  39.                                   Fax: +47 82 44 160
  40.                                    BIXname: thvaring
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  66.  
  67.  
  68.  
  69.  
  70.         CRON User's Guide            Rev. 01-20-91                   Contents-1
  71.  
  72.  
  73.  
  74.                                    TABLE OF CONTENTS
  75.  
  76.  
  77.  
  78.      1    INTRODUCTION  . . . . . . . . . . . . . . . . . . . . . . . . . .   1
  79.           1.1 Product Description   . . . . . . . . . . . . . . . . . . . .   1
  80.           1.2 Shareware   . . . . . . . . . . . . . . . . . . . . . . . . .   2
  81.           1.3 Acknowledgements  . . . . . . . . . . . . . . . . . . . . . .   2
  82.           1.4 System Requirements   . . . . . . . . . . . . . . . . . . . .   2
  83.           1.5 Feedback  . . . . . . . . . . . . . . . . . . . . . . . . . .   2
  84.  
  85.      2    INSTALLATION  . . . . . . . . . . . . . . . . . . . . . . . . . .   3
  86.           2.1 Archive Contents  . . . . . . . . . . . . . . . . . . . . . .   3
  87.           2.2 Installing CRON   . . . . . . . . . . . . . . . . . . . . . .   3
  88.           2.3 Setting up CRON's environment   . . . . . . . . . . . . . . .   3
  89.           2.4 Set Your Clock  . . . . . . . . . . . . . . . . . . . . . . .   4
  90.  
  91.      3    USING CRON  . . . . . . . . . . . . . . . . . . . . . . . . . . .   5
  92.           3.1 Command-line Summary  . . . . . . . . . . . . . . . . . . . .   5
  93.           3.2 Crontab override -- the '-c tab' option   . . . . . . . . . .   5
  94.           3.3 Disable logging -- the '-n' option  . . . . . . . . . . . . .   6
  95.           3.4 Swap Mode -- the '-s', '-d dir' and '-e' options  . . . . . .   6
  96.           3.5 Verbose mode -- the '-v' option   . . . . . . . . . . . . . .   6
  97.           3.6 Locking the logfile -- the '-L' and '-l' option   . . . . . .   7
  98.           3.7 Stopping CRON   . . . . . . . . . . . . . . . . . . . . . . .   7
  99.           3.8 Startup Information   . . . . . . . . . . . . . . . . . . . .   7
  100.  
  101.      4    THE CRONTAB IN DETAIL   . . . . . . . . . . . . . . . . . . . . .   8
  102.           4.1 Syntax Summary  . . . . . . . . . . . . . . . . . . . . . . .   8
  103.           4.2 The Date and Time fields  . . . . . . . . . . . . . . . . . .   8
  104.           4.3 The Command Field   . . . . . . . . . . . . . . . . . . . . .   9
  105.  
  106.      5    THE CRONLOG IN DETAIL   . . . . . . . . . . . . . . . . . . . . .  12
  107.           5.1 General Description   . . . . . . . . . . . . . . . . . . . .  12
  108.           5.2 Starting And Stopping CRON  . . . . . . . . . . . . . . . . .  12
  109.           5.3 Start and Stop of CRONTAB Entry Processing  . . . . . . . . .  13
  110.           5.4 Logging Multi-Command Execution   . . . . . . . . . . . . . .  14
  111.  
  112.      6    ERROR HANDLING  . . . . . . . . . . . . . . . . . . . . . . . . .  15
  113.           6.1 General Considerations  . . . . . . . . . . . . . . . . . . .  15
  114.           6.2 Failure to Spawn a Command  . . . . . . . . . . . . . . . . .  16
  115.           6.3 A Spawned Command Fails   . . . . . . . . . . . . . . . . . .  16
  116.           6.4 Other Internal CRON errors  . . . . . . . . . . . . . . . . .  17
  117.           6.5 Exit Codes and COMMAND.COM  . . . . . . . . . . . . . . . . .  17
  118.  
  119.      7    ADVANCED TOPICS   . . . . . . . . . . . . . . . . . . . . . . . .  18
  120.           7.1 Resource Requirements   . . . . . . . . . . . . . . . . . . .  18
  121.           7.2 Using CRON with DESQview  . . . . . . . . . . . . . . . . . .  18
  122.           7.3 CRON Technical Information  . . . . . . . . . . . . . . . . .  19
  123.           7.4 Differences between CRON and UNIX cron  . . . . . . . . . . .  19
  124.           7.5 CRONDV.EXE  . . . . . . . . . . . . . . . . . . . . . . . . .  21
  125.                7.5.1 What Is CRONDV.EXE?  . . . . . . . . . . . . . . . . .  21
  126.                7.5.2 How it Works   . . . . . . . . . . . . . . . . . . . .  21
  127.  
  128.  
  129.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  130.  
  131.  
  132.  
  133.  
  134.         CRON User's Guide            Rev. 01-20-91                   Contents-2
  135.  
  136.  
  137.                7.5.3 The CRONPIF Environment Variable   . . . . . . . . . .  21
  138.                7.5.4 CRONLOG entries  . . . . . . . . . . . . . . . . . . .  22
  139.                7.5.5 About Programs spawned by CRONDV   . . . . . . . . . .  22
  140.                7.5.6 Command-line Options   . . . . . . . . . . . . . . . .  22
  141.  
  142.      8    REFERENCE SECTION   . . . . . . . . . . . . . . . . . . . . . . .  23
  143.           8.1 Error Messages  . . . . . . . . . . . . . . . . . . . . . . .  23
  144.           8.2 Exit Codes  . . . . . . . . . . . . . . . . . . . . . . . . .  24
  145.                8.2.1 Common Exit Codes  . . . . . . . . . . . . . . . . . .  24
  146.                8.2.2 Swap Mode  . . . . . . . . . . . . . . . . . . . . . .  25
  147.                8.2.3 Non-Swap Mode  . . . . . . . . . . . . . . . . . . . .  25
  148.                8.2.4 RC = -1 for '!' Commands   . . . . . . . . . . . . . .  25
  149.  
  150.      9    UTILITY PROGRAMS  . . . . . . . . . . . . . . . . . . . . . . . .  26
  151.           9.1 CDD.EXE   . . . . . . . . . . . . . . . . . . . . . . . . . .  26
  152.           9.2 LOGCHECK.EXE  . . . . . . . . . . . . . . . . . . . . . . . .  26
  153.  
  154.      10  PROGRAM HISTORY  . . . . . . . . . . . . . . . . . . . . . . . . .  28
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  194.  
  195.  
  196.  
  197.  
  198.         CRON User's Guide            Rev. 01-20-91                       Page 1
  199.  
  200.  
  201.         1 INTRODUCTION
  202.  
  203.  
  204.  
  205.         1.1 Product Description
  206.  
  207.         This is version 1.6 of CRON.
  208.  
  209.         CRON is a timed command dispatcher that closely implements all the
  210.         features of the UNIX 'cron' utility that make sense in a DOS
  211.         environment.
  212.  
  213.         CRON reads a special file at startup, conventionally called CRONTAB,
  214.         where each entry defines a time and a command to execute at that time.
  215.         All commands are periodic, i.e. one-shot commands are not possible. The
  216.         longest period is one year, however, so this is not considered a
  217.         problem. In a PC environment, a command with a 1-year period is a one-
  218.         shot command for all practical purposes.
  219.  
  220.         After a command has executed, CRON re-calculates its next execution
  221.         time, then sorts the command list in time order and waits until the
  222.         first command in the list is due for execution. This sequence is
  223.         repeated undefinitely (or until the user stops CRON).
  224.  
  225.         CRON optionally logs its activites in a file conventionally called
  226.         CRONLOG. The layout of this file is more or less identical to the UNIX
  227.         cronlog and conveys the same information. The cronlog maintains an
  228.         accurate track of CRON's activities. A startup option is available to
  229.         make CRON lock the log file during access, allowing several
  230.         workstations on a network to run CRON with a central logfile on the
  231.         server.
  232.  
  233.         CRON works well with DESQview. Under DESQview, the background operation
  234.         of UNIX cron can be emulated by letting CRON run by itself in a (small)
  235.         window. Indeed, CRON was originally developed for use with DESQview.
  236.         See chapter 7 for instructions on using CRON with DESQview, and for
  237.         information about the special CRONDV program for spawning xx-pif.dvp
  238.         files.
  239.  
  240.         Although based on UNIX cron, CRON is developed from scratch and
  241.         contains no proprietary code.
  242.  
  243.         CRON.EXE has been reported to work fine with Microsoft Windows 3.0,
  244.         although I have not tested this.
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  258.  
  259.  
  260.  
  261.  
  262.         CRON User's Guide            Rev. 01-20-91                       Page 2
  263.  
  264.  
  265.         1.2 Shareware
  266.  
  267.         CRON is shareware (aka. User Supported Software). This means that you
  268.         may freely use CRON for a reasonable evaluation period. You may also
  269.         freely distribute CRON11.ZIP in unmodified form, to BBS'es or
  270.         otherwise.
  271.  
  272.         If, after a reasonable evaluation period, you find CRON useful, I would
  273.         appreciate a contribution. NOK 150 (USD 25) suggested.
  274.  
  275.         All the usual disclaimers about damages, fitness for any particular
  276.         purpose and all that apply. In brief, you use CRON at your own risks
  277.         and perils.
  278.  
  279.         The contents of the CRON16.ZIP archive are Copyright (C) 1990-1991 by
  280.         Tron Hvaring.
  281.  
  282.  
  283.  
  284.         1.3 Acknowledgements
  285.  
  286.         Thanks to Thomas Wagner, Berlin, Germany for his EXEC routines (public
  287.         domain software, available as EXEC23.LZH on many BBS'es), on which
  288.         CRON's swap logic is based, and to Borland International for their
  289.         splendid debugger.
  290.  
  291.         Thanks to Julian Templeton, London, for suggesting the new character
  292.         escape facility.
  293.  
  294.  
  295.  
  296.         1.4 System Requirements
  297.  
  298.         CRON runs on any IBM PC compatible computer under the DOS operating
  299.         system, version 3 or later. CRON requires a minimum of 44KB of free
  300.         memory to load, more for large CRONTABS. The special version CRONDV.EXE
  301.         runs on the same hardware but only under DESQview.
  302.  
  303.  
  304.  
  305.         1.5 Feedback
  306.  
  307.         Your comments, suggestions and bug reports are most welcome. Since CRON
  308.         implements all the features of UNIX cron that make sense in a DOS
  309.         environment, new functionality is not likely to be added if not
  310.         sollicited by users. Bug reports, on the other hand, is a different
  311.         story.
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  322.  
  323.  
  324.  
  325.  
  326.         CRON User's Guide            Rev. 01-20-91                       Page 3
  327.  
  328.  
  329.         2 INSTALLATION
  330.  
  331.  
  332.  
  333.         2.1 Archive Contents
  334.  
  335.         This archive should contain the following files:
  336.  
  337.           -    CRON.EXE,      the executable program
  338.           -    CRONDV.EXE,    special executable for running DESQview
  339.                               xx-PIF.DVP files, see chapter 7.
  340.           -    CRON.DOC,      this document
  341.           -    CRONTAB,       annotated sample crontab
  342.           -    CRONTAB.DV,    annotated sample crontab for CRONDV
  343.           -    LOGCHECK.EXE,  let CRON control its log size
  344.           -    CDD.EXE        smarter CHDIR command
  345.           -    READ.ME        list of fixes and new features in this version
  346.  
  347.  
  348.  
  349.         2.2 Installing CRON
  350.  
  351.         Copy CRON.EXE/CRONDV.EXE to a directory in the DOS PATH (e.g. c:\bin).
  352.  
  353.         Create a directory for CRON's use, for example C:\CRON.
  354.  
  355.         This directory should be used for crontabs and log files.
  356.  
  357.         Create your crontab using the supplied CRONTAB as a template. Read the
  358.         rest of this document for more information about crontabs. Put your
  359.         crontab in the directory you created.
  360.  
  361.  
  362.  
  363.         2.3 Setting up CRON's environment
  364.  
  365.         CRON recognizes several environment variables. These are:
  366.  
  367.           CRONTAB   if set, CRON assumes it contains the name of a file that is
  368.                     to be used as the crontab. This can be overridden on the
  369.                     command line. Typically, this environment variable will
  370.                     contain C:\CRON\CRONTAB.
  371.  
  372.           CRONLOG   required if you want CRON to log its operations. Set to the
  373.                     name of the logfile (e.g. C:\CRON\CRONLOG). Note that
  374.                     CRONLOG must point to a fully qualified file name,
  375.                     including drive/path. This is required since the commands
  376.                     that CRON execute may change the logged drive and/or
  377.                     directory.
  378.  
  379.           TZ        indirectly consulted by the time management functions of
  380.                     the run-time library. If you live in a country that uses
  381.                     daylight savings, TZ must be set for CRON to operate
  382.  
  383.  
  384.  
  385.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  386.  
  387.  
  388.  
  389.  
  390.         CRON User's Guide            Rev. 01-20-91                       Page 4
  391.  
  392.  
  393.                     correctly when the daylight savings period changes (twice a
  394.                     year). Syntax is:
  395.                          TZ=<time zone><hours after GMT><daylight saving>
  396.                     where <time zone> and <daylight saving> *must* be three-
  397.                     character upper-case strings, and <hours after GMT> is a
  398.                     signed number, positive westwards and negative eastwards
  399.                     relative to Greenwich. The actual contents of the character
  400.                     strings is irrelevant -- only their presence count. A
  401.                     correct value for Norway is
  402.                          TZ=CET-1CDT
  403.                     whereas a correct value for the UK is
  404.                          TZ=GMT0GDT
  405.                     If your country does not practice daylight saving, omit the
  406.                     last string, e.g. TZ=CET-1 if Norway hadn't practiced
  407.                     daylight saving.
  408.  
  409.           TMP       if CRON is run in swap mode, it will swap most of itself
  410.                     out of memory when executing commands. By default, CRON
  411.                     will swap to a temporary file in the directory named by the
  412.                     TMP variable, or in the current directory if the TMP
  413.                     directory does not exist. If you have a RAM disk with 50-
  414.                     70K of free space, set TMP to the name of directory on this
  415.                     RAM disk. The directory used for swapping can be overridden
  416.                     on the command line.
  417.  
  418.           COMSPEC   when CRON needs to spawn COMMAND.COM, it will use the name
  419.                     contained in this variable, which is normally
  420.                     C:\COMMAND.COM. Other shells, like 4DOS, can be used by
  421.                     setting COMSPEC appropriately.
  422.  
  423.  
  424.           CRONPIF   see chapter 7.5. This is the directory where CRONDV looks
  425.                     for xx-pif.dvp files to execute.
  426.  
  427.  
  428.         Setting these environment variables allows you to start CRON with the
  429.         appropriate environment by simply typing CRON.
  430.  
  431.         Here's a selected part of my AUTOEXEC.BAT:
  432.  
  433.           SET CRONTAB=d:\cron\crontab
  434.           SET CRONLOG=d:\cron\cronlog
  435.           SET TMP=m:\tmp
  436.           SET TZ=CET-1CDT
  437.  
  438.  
  439.  
  440.         2.4 Set Your Clock
  441.  
  442.         CRON will not operate as expected if the DOS date and time are not set
  443.         correctly. In particular, remember to update your clock when crossing
  444.         daylight savings zone boundaries.
  445.  
  446.  
  447.  
  448.  
  449.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  450.  
  451.  
  452.  
  453.  
  454.         CRON User's Guide            Rev. 01-20-91                       Page 5
  455.  
  456.  
  457.         3 USING CRON
  458.  
  459.  
  460.         See chapter 7 for further instructions regarding CRONDV.EXE.
  461.  
  462.  
  463.  
  464.         3.1 Command-line Summary
  465.  
  466.         CRON is started as follows:
  467.  
  468.           CRON [option] [option] ...
  469.  
  470.  
  471.         As a special case, entering "CRON ?" will display an option summary and
  472.         terminate.
  473.  
  474.         The available options are:
  475.  
  476.           -c tab    -- override CRONTAB name
  477.           -n        -- no log
  478.           -s        -- swap mode
  479.           -e        -- swap to LIM/EMS memory if possible
  480.           -d dir    -- swap directory override
  481.           -v        -- verbose mode
  482.           -l        -- lock CRONLOG when accessing if on network drive
  483.           -L        -- always lock CRONLOG when accessing
  484.  
  485.  
  486.  
  487.         3.2 Crontab override -- the '-c tab' option
  488.  
  489.         This option overrides the name that CRON will use for the crontab.
  490.         'tab' must be the name of an existing file. Full drive/path syntax or
  491.         relative syntax may be used.
  492.  
  493.         In the absence of this option, CRON will look for the crontab as
  494.         follows:
  495.  
  496.           -    if the CRONTAB environment variable is set, use that name
  497.           -    otherwise, look in the directory that was current when CRON was
  498.                started for the file name "CRONTAB".
  499.  
  500.         CRON will complain and abort if it cannot find a crontab.
  501.  
  502.         Example (friday afternoon):
  503.  
  504.           cron -c d:\cron\weekend
  505.  
  506.         Note that CRON only reads the crontab at startup.
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  514.  
  515.  
  516.  
  517.  
  518.         CRON User's Guide            Rev. 01-20-91                       Page 6
  519.  
  520.  
  521.         3.3 Disable logging -- the '-n' option
  522.  
  523.         If CRON is set up for logging, this option disables logging. If CRON
  524.         would not have logged anyway the option is ignored.
  525.  
  526.         Logging is only done if the environment variable CRONLOG is set to a
  527.         fully qualified filename (i.e. with full drive/path syntax).
  528.  
  529.         CRON will complain if CRONLOG is set but does not point to a fully
  530.         qualified filename.
  531.  
  532.  
  533.  
  534.         3.4 Swap Mode -- the '-s', '-d dir' and '-e' options
  535.  
  536.         CRON may optionally swap most of itself out of memory when executing
  537.         other commands. This feature is enabled by entering the -s option.
  538.  
  539.         CRON will by default swap to a temporary file, either in the TMP
  540.         directory if set, or in the directory that was current when CRON was
  541.         started.
  542.  
  543.         The -e option will make CRON try to swap itself to LIM/EMS memory, if
  544.         present and available in sufficient quantities. See chapter 7 for a
  545.         discussion of memory requirements. If EMS swapping is not possible,
  546.         CRON reverts to disk swapping.
  547.  
  548.         The '-d dir' option will make CRON swap to a temporary file in the
  549.         directory 'dir' instead of the standard places described above.
  550.  
  551.         CRON complains if it sees -d or -e but not -s, and if 'dir' is not a
  552.         valid directory.
  553.  
  554.  
  555.  
  556.         3.5 Verbose mode -- the '-v' option
  557.  
  558.         This option requires that an ANSI driver be present in your system,
  559.         e.g. ANSI.SYS, or DVANSI.COM under DESQview.
  560.  
  561.         The effect of -v is that CRON maintains a real time display showing the
  562.         next command scheduled for execution, the time it will be executed, and
  563.         the time left (in seconds) until the command is executed.
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  578.  
  579.  
  580.  
  581.  
  582.         CRON User's Guide            Rev. 01-20-91                       Page 7
  583.  
  584.  
  585.         3.6 Locking the logfile -- the '-L' and '-l' options
  586.  
  587.         If one of these options is entered, CRON will lock byte 0 of the
  588.         logfile before accessing it, using the DOS 3.1 locking calls.
  589.  
  590.         CRON uses the IOCTL Is Redirected Handle call to determine if the
  591.         logfile is on a network drive. Your DOS version must support this call
  592.         (DOS function 44H, subfunction 0AH) for logfile locking to work with
  593.         the '-l' option. If you enter the '-L' option CRON will not check if
  594.         the file is remote but will always try to lock it. This is useful if
  595.         you have loaded SHARE.EXE on the local machine.
  596.  
  597.         Most networks support the DOS 3.1 locking calls. CRON has also been
  598.         tested and found to work fine on a Novell NetWare network.
  599.  
  600.         If your network does not support the way CRON goes about locking the
  601.         logfile, CRON will still work but will simply disable logfile locking.
  602.  
  603.         If a lock call fails (either because of a timeout or because you used
  604.         the '-L' option and the locking call failed), CRON will print a
  605.         timestamped error message and disable locking and verbose mode.
  606.  
  607.  
  608.  
  609.         3.7 Stopping CRON
  610.  
  611.         CRON is stopped by typing ESC. CRON reminds you of this at startup.
  612.  
  613.  
  614.  
  615.         3.8 Startup Information
  616.  
  617.         When CRON starts, it will print a banner consisting of the program
  618.         name, version, copyright, memory available after CRON has processed the
  619.         crontab and grabbed what it needs, and a reminder that you should hit
  620.         ESC to stop CRON.
  621.  
  622.         If CRON believes that it runs under DESQview, it will print the
  623.         additional line '(DESQview detected)'.
  624.  
  625.         In verbose mode, CRON will then print information about the first
  626.         command to execute, and start its real-time second countdown.
  627.  
  628.         If this information looks funny (displaying left arrows and '['
  629.         characters) you don't have an ANSI driver resident. Put the line
  630.  
  631.           DEVICE=[drive:\path\]ANSI.SYS
  632.  
  633.         in your CONFIG.SYS file, or load DVANSI.COM before starting CRON if
  634.         running under DESQview.
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  642.  
  643.  
  644.  
  645.  
  646.         CRON User's Guide            Rev. 01-20-91                       Page 8
  647.  
  648.  
  649.         4 THE CRONTAB IN DETAIL
  650.  
  651.  
  652.  
  653.         4.1 Syntax Summary
  654.  
  655.         CRONTAB is a regular ASCII text file that can be created by any editor
  656.         or word processor in non-document mode.
  657.  
  658.         Lines containing a '#' character in column 1, and blank lines, are
  659.         ignored (useful for commenting crontabs).
  660.  
  661.         All other lines are interpreted as CRONTAB ENTRIES. A CRONTAB entry has
  662.         the following format:
  663.  
  664.         minute   hour   day   month   day-of-week   command
  665.  
  666.         Fields are separated by any number of tabs or spaces. No tabs or spaces
  667.         are allowed inside the first 5 fields. Maximum line length is 512
  668.         characters including the trailing CR/LF pair.
  669.  
  670.  
  671.  
  672.         4.2 The Date and Time fields
  673.  
  674.         These fields can have the following forms:
  675.  
  676.           *         all legal values
  677.           i,j,k     sequence of values
  678.           i-j       inclusive range of values
  679.  
  680.         The sequence and range forms may be combined, as in
  681.  
  682.           1,3,5,7-9,11,13-17,19
  683.  
  684.         An asterisk '*' overrides any other value in a field. Thus
  685.  
  686.           1,3,*,5,7
  687.  
  688.         is equivalent to
  689.  
  690.           *
  691.  
  692.         Legal ranges for the different fields are as follows:
  693.  
  694.           minute         -- 0..59
  695.           hour           -- 0..23 (24-hour clock)
  696.           day            -- 1..31 (must be consistent with month)
  697.           month          -- 1..12
  698.           day-of-week    -- 0..6, 0 = Sunday, 1 = Monday etc.
  699.  
  700.  
  701.         CRON detects values that are out of range, and impossible dates (like
  702.         February 31.).
  703.  
  704.  
  705.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  706.  
  707.  
  708.  
  709.  
  710.         CRON User's Guide            Rev. 01-20-91                       Page 9
  711.  
  712.  
  713.  
  714.         The actual execution times computed by CRON is the largest matching set
  715.         of times. This is best explained by the following example:
  716.  
  717.           54 6 1,15 * 1 doreport
  718.  
  719.         means that the command 'doreport' will be executed at 06:54 on the 1.
  720.         and 15. of every month (month = '*'), AND on each monday (day-of-week =
  721.         1). If the 1. or 15. falls on a Monday, 'doreport' will not be executed
  722.         twice.
  723.  
  724.         The extremes in terms of periodicity are:
  725.  
  726.         * * * * * dooften     -- executes 'dooften' every minute
  727.         1 0 1 1 * calendar    -- executes 'calendar' at 00:01 each January 1.
  728.  
  729.  
  730.  
  731.         4.3 The Command Field
  732.  
  733.         The 'command' field of a CRONTAB entry consists of one or more COMMAND
  734.         LINES, separated by semicolons ';'. If the command field contains only
  735.         one command line, it should not be terminated by a semicolon.
  736.  
  737.         A COMMAND LINE obeys the following syntax:
  738.  
  739.           [~][!]DOS command line
  740.  
  741.         i.e. an optional '~' character, followed by an optional '!' character,
  742.         followed by a regular DOS command line.
  743.  
  744.         Thus a command field looks like
  745.  
  746.           [~][!]command line;[~][!]command line;[~][!]command line....
  747.  
  748.         or
  749.  
  750.           [~][!]command line
  751.  
  752.  
  753.         The '~' character means 'NOSWAP'. It means that CRON should not swap
  754.         itself out when executing this command, even if swapping is enabled. If
  755.         swapping is disabled, the character is ignored. This feature is useful
  756.         for small commands that require modest amounts of memory.
  757.  
  758.         If both '~' and '!' are entered, '~' must precede '!'.
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  770.  
  771.  
  772.  
  773.  
  774.         CRON User's Guide            Rev. 01-20-91                      Page 10
  775.  
  776.  
  777.         IMPORTANT NOTE:
  778.         ---------------
  779.  
  780.         if any 'command line' contains path separator characters (i.e. '\'
  781.         inside pathnames) each '\' must be entered TWICE. This is because
  782.         starting with V1.6, CRON assumes that '\' is an escape character,
  783.         causing the next character to be processed literally (even if it is a
  784.         '!', a '~' or a ';'). Thus
  785.  
  786.           cdd d:\mypath
  787.  
  788.         will not work as expected, whereas
  789.  
  790.           cdd d:\\mypath
  791.  
  792.         will.
  793.  
  794.  
  795.         The '!' character is a synonym for %COMSPEC% /C, i.e. the contents of
  796.         the environment variable COMSPEC, followed by the string " /C ".
  797.  
  798.         Thus the command lines
  799.  
  800.           !dir
  801.  
  802.         and
  803.  
  804.           COMMAND /C dir
  805.  
  806.         are equivalent, provided COMSPEC points to COMMAND.COM.
  807.  
  808.         '!' (or its synonym) is *required* for COMMAND.COM internal commands,
  809.         like DIR, DEL and CD.
  810.  
  811.         '!' (or its synonym) is optional for executable programs, including
  812.         .BAT files.
  813.  
  814.         If your command uses redirection (i.e. <, >, >> or |), '!' is required
  815.         since redirection is handled by COMMAND.COM. Otherwise it should not be
  816.         used, as it adds no functionality except consuming a few K of
  817.         additional memory.
  818.  
  819.         Thus the command line
  820.  
  821.           sort <infile >outfile
  822.  
  823.         will not work as expected, but
  824.  
  825.           !sort <infile >outfile
  826.  
  827.         will.
  828.  
  829.  
  830.  
  831.  
  832.  
  833.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  834.  
  835.  
  836.  
  837.  
  838.         CRON User's Guide            Rev. 01-20-91                      Page 11
  839.  
  840.  
  841.         Note that CRON knows about .BAT files and will spawn COMMAND.COM
  842.         internally for them. Therefore, the '!' prefix is not needed for .BAT
  843.         files.
  844.  
  845.         When locating the command to execute, CRON follows the standard DOS
  846.         algorithm: first look in the current directory, then in each directory
  847.         along the PATH, respecting the search order for .COM, .EXE and .BAT
  848.         files. Thus CRONTAB command lines may be entered exactly as if you were
  849.         at the DOS prompt, except for the '!' prefix (which is implicit when at
  850.         the DOS command line).
  851.  
  852.         CRON sets the logged drive and directory to their startup values (i.e.
  853.         the drive and directory that were current when CRON started) before
  854.         executing a CRONTAB entry.
  855.  
  856.  
  857.         If an entry contains multiple command lines, the logged drive and
  858.         directory are not reset between command lines. This allows entries such
  859.         as:
  860.  
  861.         57 5 1,15 * * ~!d:;~!cd \\acct\\dbase;misreport
  862.  
  863.         assuming that the program 'misreport' expects to be run from the
  864.         'D:\ACCT\DBASE' directory.
  865.  
  866.         The enclosed file CRONTAB contains several commented CRONTAB entries.
  867.  
  868.         See chapter 9 for a description of the enclosed utilities that are
  869.         useful in CRONTAB entries.
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  898.  
  899.  
  900.  
  901.  
  902.         CRON User's Guide            Rev. 01-20-91                      Page 12
  903.  
  904.  
  905.         5 THE CRONLOG IN DETAIL
  906.  
  907.  
  908.  
  909.         5.1 General Description
  910.  
  911.         The optional CRONLOG is a text file produced by CRON where all its
  912.         operations and their results are logged.
  913.  
  914.         CRONLOG is a plain ASCII text file with highly structured lines.
  915.         Cronlogs are suitable for automatic processing, for example with AWK or
  916.         similar utilities.
  917.  
  918.         The cronlog is always opened in APPEND mode, so it is ever-increasing.
  919.         The utility LOGCHECK.EXE (documented later) can be used to control the
  920.         size of the cronlog.
  921.  
  922.         CRON produces a log entry when:
  923.  
  924.           -    CRON is started
  925.           -    CRON is stopped
  926.           -    CRON starts to execute a CRONTAB entry
  927.           -    CRON has finished to execute a CRONTAB entry
  928.           -    CRON starts to execute subsequent command lines in a multi-
  929.                command entry
  930.           -    CRON has finished to execute a command line in a multi-command
  931.                entry.
  932.  
  933.         Entries have the following general format:
  934.  
  935.         <entry token> <operation> <date and time> <additional data>
  936.  
  937.  
  938.  
  939.         5.2 Starting And Stopping CRON
  940.  
  941.         These lines are as follows:
  942.  
  943.         !cron started at Fri Oct 19 13:22:35 1990
  944.         !cron stopped at Fri Oct 19 13:22:51 1990
  945.  
  946.         No further comments should be necessary.
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  962.  
  963.  
  964.  
  965.  
  966.         CRON User's Guide            Rev. 01-20-91                      Page 13
  967.  
  968.  
  969.         5.3 Start and Stop of CRONTAB Entry Processing
  970.  
  971.         When CRON starts executing a CRONTAB entry, it produces a log record
  972.         starting with the character '>'.
  973.  
  974.         A typical entry is as follows:
  975.  
  976.         > 'mapmem -v' Fri Oct 19 13:43:00 1990
  977.  
  978.         meaning that the command field 'mapmem -v' started to execute on the
  979.         indicated date and time.
  980.  
  981.  
  982.         When the command returns, CRON produces a log entry starting with the
  983.         '<' character, as follows:
  984.  
  985.         < 'mapmem -v' Fri Oct 19 13:43:00 1990, rc = 0
  986.  
  987.         meaning that the command 'mapmem -v' executed until the indicated date
  988.         and time (in this example, for less than 1 second), and returned with
  989.         an exit code 0 ('rc = 0').
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  1026.  
  1027.  
  1028.  
  1029.  
  1030.         CRON User's Guide            Rev. 01-20-91                      Page 14
  1031.  
  1032.  
  1033.         5.4 Logging Multi-Command Execution
  1034.  
  1035.         For CRONTAB entries containing multiple command lines, CRON produces a
  1036.         sequence of records bracketed by a '>' entry, marking the start of the
  1037.         entry as a whole, and a '<' entry, marking the end of the entry as a
  1038.         whole. Between these entries, a pair or '>>' (start of command) and
  1039.         '<<' (end of command) is produced for each command line in the entry,
  1040.         including the first.
  1041.  
  1042.         The text of the '>' and '<' entries contain the entire command field.
  1043.         The text of the '>>' and '<<' entries contain the individual command
  1044.         lines, *without* any '!' or '~' prefix. These prefixes appear in the
  1045.         bracketing lines, though.
  1046.  
  1047.         A sample sequence is shown below, corresponding to the CRONTAB entry
  1048.  
  1049.           54 16 * * * !d:;!cd \\cron;mapmem -v
  1050.  
  1051.         > '!d:;!cd \cron;mapmem -v' Fri Oct 19 16:54:00 1990
  1052.         >> 'd:' Fri Oct 19 16:54:00 1990
  1053.         << 'd:' Fri Oct 19 16:54:00 1990, rc = 0
  1054.         >> 'cd \cron' Fri Oct 19 16:54:00 1990
  1055.         << 'cd \cron' Fri Oct 19 16:54:00 1990, rc = 0
  1056.         >> 'mapmem -v' Fri Oct 19 16:54:00 1990
  1057.         << 'mapmem -v' Fri Oct 19 16:54:01 1990, rc = 0
  1058.         < '!d:;!cd \cron;mapmem -v' Fri Oct 19 16:54:01 1990, rc = 0
  1059.  
  1060.         Exit codes are only produced for '<' and '<<' entries. See the next
  1061.         chapter for a discussion of how to interpret these codes.
  1062.  
  1063.         Some '<' and '<<' entries may contain the string "*** FAILED ***". This
  1064.         means that an error occured. See the next chapter for an interpretation
  1065.         of such entries.
  1066.  
  1067.         In a bracket '<' line, the 'rc = n' field has the same value as the
  1068.         last sub-command that was executed.
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  1090.  
  1091.  
  1092.  
  1093.  
  1094.         CRON User's Guide            Rev. 01-20-91                      Page 15
  1095.  
  1096.  
  1097.         6 ERROR HANDLING
  1098.  
  1099.  
  1100.  
  1101.         6.1 General Considerations
  1102.  
  1103.         Errors may occur for several reasons:
  1104.  
  1105.           -    CRON does not have enough resources to run
  1106.           -    CRON may be unable to locate or spawn a command
  1107.           -    a critical error can hit CRON (logfile disk full, swap error)
  1108.           -    the spawned command can fail
  1109.           -    a critical error can hit a spawned command
  1110.           -    a spawned command may encounter an internal exception requiring
  1111.                user intervention (i.e. the command prompts for keyboard input).
  1112.  
  1113.         If a critical error occurs -- either inside CRON or in a spawned
  1114.         command -- you are simply out of luck, since the infamous 'Abort,
  1115.         Retry, Ignore' requires user intervention (i.e. keyboard input).
  1116.  
  1117.         I considered trapping critical errors within CRON, but decided against
  1118.         it. Since CRON is typically run on an unattended system, and since CRON
  1119.         cannot know whether or not a spawned command has put the system into an
  1120.         unstable state, we cannot be quite sure that a 'disk full' error really
  1121.         means that the disk is full. To prevent disaster we simply let the
  1122.         standard DOS error handling take over, suspending everything until a
  1123.         human can take over. This is also known as the 'better safe than sorry'
  1124.         strategy.
  1125.  
  1126.         CRON relies on the fact that a spawned command will eventually return.
  1127.         If the command decides it wants keyboard input, and no one is around,
  1128.         CRON will be suspended until someone comes around to hit the keyboard.
  1129.         The net effect of a critical error hitting a spawned command is the
  1130.         same.
  1131.  
  1132.         The bottom line is that you should make sure no critical errors will
  1133.         occur when leaving CRON in charge of an unattended system.
  1134.         Specifically, make sure that all required peripherals are online, that
  1135.         any addressed printers are online and have enough paper, et cetera, et
  1136.         cetera. Also, make sure that spawned commands are started in such a way
  1137.         that they won't ever require keyboard input.
  1138.  
  1139.         Perhaps one day I'll understand what is so critical about a printer
  1140.         being out of paper, and why that condition is handled in the same way
  1141.         as a hard disk CRC error. Or perhaps I won't.
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  1154.  
  1155.  
  1156.  
  1157.  
  1158.         CRON User's Guide            Rev. 01-20-91                      Page 16
  1159.  
  1160.  
  1161.         6.2 Failure to Spawn a Command
  1162.  
  1163.         CRON may fail trying to spawn a command. This is reflected by a log
  1164.         entry of the '<' or '<<' variety, with 'rc = -1'. If swapping is not
  1165.         enabled, an additional 'errno = n' is appended to the entry. See
  1166.         chapter 8 for interpretation of errno values.
  1167.  
  1168.         If swapping is enabled, 'rc = -1' always means that CRON could not
  1169.         locate the executable file. This may be caused by:
  1170.  
  1171.           -    you forgot to prefix a COMMAND.COM internal command with '!'
  1172.           -    the command does not exist in the current directory, nor in any
  1173.                directory in the current PATH.
  1174.  
  1175.         If a command name is given without an extension, CRON will try .COM,
  1176.         .EXE and .BAT exactly like COMMAND.COM does.
  1177.  
  1178.         If a '!' style command returns an exit code of -1, it means that the
  1179.         command interpreter itself failed to load. This is normally a serious
  1180.         condition, with possible causes:
  1181.  
  1182.           -    the command named by COMSPEC has disappeared or is no longer in
  1183.                the DOS PATH
  1184.           -    the COMSPEC environment variable has been corrupted
  1185.           -    the PATH environment variable has been corrupted
  1186.  
  1187.         If swapping is not enabled, 'errno' contains further information. If
  1188.         swapping is enabled, one of the three causes above apply.
  1189.  
  1190.  
  1191.  
  1192.         6.3 A Spawned Command Fails
  1193.  
  1194.         This is indicated by an exit code in the range 0..255. It means that
  1195.         CRON could spawn the command, and that the command itself returned a
  1196.         non-0 exit code when issuing the DOS TERMINATE call.
  1197.  
  1198.         CRON's actions depend on whether or not the current entry contains
  1199.         multiple commands.
  1200.  
  1201.         If the command was the only command in the CRONTAB entry, CRON simply
  1202.         records the exit code in the log (if enabled) and proceeds to schedule
  1203.         the next command. The philosophy behind this is that a failure in one
  1204.         crontab entry should not influence the operation of other, possible
  1205.         unrelated, crontab entries.
  1206.  
  1207.         If the command was part of a multi-command entry, CRON assumes that all
  1208.         commands in the entry are somewhat interdependent and therefore aborts
  1209.         execution of remaining commands in the entry, logging this fact if
  1210.         logging is enabled.
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  1218.  
  1219.  
  1220.  
  1221.  
  1222.         CRON User's Guide            Rev. 01-20-91                      Page 17
  1223.  
  1224.  
  1225.         The CDD.EXE utility (documented in a later chapter) is a more
  1226.         intelligent alternative to COMMAND.COM's builtin CHDIR command. The
  1227.         crontab entry
  1228.  
  1229.           38 04 * * * ~cdd d:\\acct\\dbase;misreport
  1230.  
  1231.         will first change the logged drive and directory to 'D:\ACCT\DBASE',
  1232.         without swapping CRON, and then execute the command 'misreport'.
  1233.         Since 'misreport' obviously wants to be run from this drive/directory,
  1234.         we had better not run it if the 'cdd' command fails. So, if cdd returns
  1235.         a non-0 exit code, 'misreport' is skipped and CRON proceeds to schedule
  1236.         the next entry after logging the failure.
  1237.  
  1238.  
  1239.  
  1240.         6.4 Other Internal CRON errors
  1241.  
  1242.         If a swap file error occurs, CRON will report an error code of 256 (rc
  1243.         = 256) for the appropriate '<' or '<<' entry and will disable swapping
  1244.         for all commands thereafter. This may cause failure of other commands
  1245.         that need so much memory that they cannot coexist with CRON in memory.
  1246.  
  1247.         Error codes starting from 768 and upwards are specific to the swapping
  1248.         interface to the EXEC function, and are documented later.
  1249.  
  1250.  
  1251.  
  1252.         6.5 Exit Codes and COMMAND.COM
  1253.  
  1254.         COMMAND.COM is too dumb to return the exit code of a command that it
  1255.         spawns, even with the /C switch.
  1256.  
  1257.         Thus, when CRON executes a '!' entry or a .BAT file, it will receive an
  1258.         exit code 0 provided COMMAND.COM itself could be spawned, but the exit
  1259.         code from the actual command is lost even if it was non-0.
  1260.  
  1261.         Thus the following crontab entry may give surprising results:
  1262.  
  1263.         12 7 * * * !z:;!cd \\absent;!XXXXXXXXXXXXX
  1264.  
  1265.         CRON will happily spawn all three commands, since spawning COMMAND.COM
  1266.         succeeds. COMMAND.COM will print something like 'Bad command or file
  1267.         name', but will still return an exit code of 0.
  1268.  
  1269.         Thus all three commands -- which failed -- show up with 'rc = 0' in the
  1270.         cronlog, since COMMAND.COM lies about the results.
  1271.  
  1272.         4DOS or some other more intelligent shell may handle this in a better
  1273.         way. For multi-command entries where changing drive and path is
  1274.         crucial, use the supplied CDD.EXE utility instead of "!d:;!cd \\path"
  1275.         constructs.
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  1282.  
  1283.  
  1284.  
  1285.  
  1286.         CRON User's Guide            Rev. 01-20-91                      Page 18
  1287.  
  1288.  
  1289.         7 ADVANCED TOPICS
  1290.  
  1291.  
  1292.  
  1293.         7.1 Resource Requirements
  1294.  
  1295.         CRON requires 44 KB of memory, plus up to 1K per 16 crontab entries.
  1296.         The number of crontab entries should be rounded up to the nearest
  1297.         multiple of 16. This is a worst-case estimate; most CRONTAB entries
  1298.         require less than 64 bytes.
  1299.  
  1300.         When swapping, CRON leaves 1.1K of itself -- plus the size of its
  1301.         environment -- in memory, swapping out the rest.
  1302.  
  1303.         When swapping to disk, CRON therefore needs (size of resident CRON -
  1304.         1.1K + pad to cluster boundary + directory overhead) bytes of disk
  1305.         space, typically less than 64K bytes.
  1306.  
  1307.         When swapping to EMS, CRON requires (size of resident CRON - 1.1K + pad
  1308.         to nearest 16K boundary) bytes, typically 3 pages = 48K bytes.
  1309.  
  1310.         For very large CRONTABS (several hundred entries) CRON may require 4
  1311.         EMS pages, i.e. 64K bytes.
  1312.  
  1313.         When swapping to disk, the swap file is closed before spawning. The
  1314.         spawned command thus has a full 20 handles available.
  1315.  
  1316.         When swapping to EMS, CRON uses 1 EMS handle which is kept across the
  1317.         EXEC call.
  1318.  
  1319.         CRON only needs EMS and disk space when a spawned command is actually
  1320.         executing. Between commands (i.e. when CRON is waiting for the next
  1321.         command to execute), no EMS or disk space is used.
  1322.  
  1323.         CRON hooks no interrupt vectors except those hooked by the run-time
  1324.         library, and does not use floating point.
  1325.  
  1326.  
  1327.  
  1328.         7.2 Using CRON with DESQview
  1329.  
  1330.         CRON works very well with DESQview. If you use DESQview, chances are
  1331.         that you have EMS in your system. If so, use the -s -e options to CRON
  1332.         for best results.
  1333.  
  1334.         CRON detects DESQview at startup. When executing its idle loop (i.e.
  1335.         waiting to execute the next command), CRON issues the 'give up time
  1336.         slice' DESQview API call. (In command line operation, CRON issues Int
  1337.         28H calls instead).
  1338.  
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  1346.  
  1347.  
  1348.  
  1349.  
  1350.         CRON User's Guide            Rev. 01-20-91                      Page 19
  1351.  
  1352.  
  1353.         CRON is generally well behaved: all output is via DOS, input is via
  1354.         BIOS keyboard calls. Does not use floating point, can (should!) run in
  1355.         the background, does not use serial lines, does not require a floppy
  1356.         disk.
  1357.  
  1358.         Note that CRON should not be swapped out by DESQview, because of its
  1359.         real-time nature. Having DESQview swap CRON would invalidate CRON's
  1360.         timing function.
  1361.  
  1362.         So, when designing a DESQview profile for CRON, you should think more
  1363.         about the programs you are spawning from CRON than about CRON itself.
  1364.  
  1365.         For example, if you spawn a telecommunications program (which is a
  1366.         natural for CRON), you should tell DESQview about which port it uses.
  1367.         Also, if a spawned program needs EMS memory, the amount should be ADDED
  1368.         to amount required by CRON if CRON is swapping to EMS.
  1369.  
  1370.         The previous subsection states the memory resources needed by CRON in
  1371.         its different operational modes. These should be added to whatever is
  1372.         required by spawned programs.
  1373.  
  1374.         See also section 7.5 for the DESQview specific version of CRON.
  1375.  
  1376.  
  1377.  
  1378.         7.3 CRON Technical Information
  1379.  
  1380.         CRON is written in C and assembler and compiled with Turbo C++ (ANSI C
  1381.         compiler mode) and TASM 2.0.
  1382.  
  1383.         The Compact memory model is used, allowing an unlimited CRONTAB size
  1384.         subject to memory constraints. Because of the way Turbo C sets up
  1385.         DGROUP, CRON actually uses LESS memory in the Compact model than in the
  1386.         Small model, for crontabs up to 2-300 entries.
  1387.  
  1388.         The CRON source code is around 2500 lines, including comments.
  1389.  
  1390.         CRON uses only documented DOS and BIOS calls. All EMS access is via
  1391.         interrupt 67H, using the approved methods to detect the presence of an
  1392.         EMS manager.
  1393.  
  1394.  
  1395.  
  1396.         7.4 Differences between CRON and UNIX cron
  1397.  
  1398.         There are two major differences between CRON and UNIX cron:
  1399.  
  1400.           -    UNIX cron runs in the background
  1401.           -    UNIX cron executes commands concurrently, while CRON executes
  1402.                commands sequentially.
  1403.  
  1404.         Under UNIX, two commands can be started by cron at the same time (well,
  1405.         almost). Under DOS, two commands scheduled to execute at the same time
  1406.         will execute one after the other, and the order of execution is random.
  1407.  
  1408.  
  1409.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  1410.  
  1411.  
  1412.  
  1413.  
  1414.         CRON User's Guide            Rev. 01-20-91                      Page 20
  1415.  
  1416.  
  1417.  
  1418.         Since UNIX cron runs in the background, and concurrently with the
  1419.         commands it spawns, a spawned command can never suspend cron. As
  1420.         described above, this may well happen with CRON in some cases.
  1421.  
  1422.         The background nature of UNIX cron can be emulated to some extent by
  1423.         running CRON under DESQview. Concurrency it not possible, however.
  1424.  
  1425.         With CRON, a command can be delayed if the previous command executes
  1426.         for a long time, i.e. past the time that the next command was due to
  1427.         execute. All commands will be executed, though. UNIX cron always starts
  1428.         commands at the scheduled times.
  1429.  
  1430.         Some of the more esoteric fields of the UNIX cronlog have been skipped,
  1431.         such as PID's of commands.
  1432.  
  1433.         The UNIX 'crontab' utility is of limited use under DOS and is not
  1434.         implemented.
  1435.  
  1436.         The LOGCHECK.EXE utility performs about the same actions as the UNIX
  1437.         /etc/logchecker shell script.
  1438.  
  1439.         UNIX cron reads all files in the /usr/spool/cron/crontabs directory as
  1440.         crontabs when it starts up -- this is the central repository of all
  1441.         user's crontabs. Since DOS's multiuser capability is somewhat limited,
  1442.         this feature was not deemed necessary. Also, hard-coded directory names
  1443.         and excessive use of environment variables are not popular in DOS
  1444.         circles.
  1445.  
  1446.         UNIX cron writes its logfile in the /usr/lib/cron directory. CRON's
  1447.         logfile is defined by the CRONLOG environment variable.
  1448.  
  1449.         UNIX cron re-reads its crontabs at run time if a crontab is modified by
  1450.         the 'crontab' utility.
  1451.  
  1452.         With CRON, you stop CRON, modify the crontab and restart CRON to
  1453.         achieve the same effect.
  1454.  
  1455.         The command-line options to CRON are not available nor useful under
  1456.         UNIX.
  1457.  
  1458.         The '~' and '!' command prefixes are specific to CRON and are not
  1459.         available (nor meaningful) with UNIX cron.
  1460.  
  1461.  
  1462.  
  1463.  
  1464.  
  1465.  
  1466.  
  1467.  
  1468.  
  1469.  
  1470.  
  1471.  
  1472.  
  1473.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  1474.  
  1475.  
  1476.  
  1477.  
  1478.         CRON User's Guide            Rev. 01-20-91                      Page 21
  1479.  
  1480.  
  1481.         7.5 CRONDV.EXE
  1482.  
  1483.  
  1484.  
  1485.         7.5.1 What Is CRONDV.EXE?
  1486.  
  1487.         CRONDV.EXE is new with version 1.6 of CRON. It can only be used with
  1488.         DESQview. The CRONTAB used with CRONDV.EXE should only contain two-
  1489.         letter commands, optionally prefixed with a drive:\\path\\,
  1490.         corresponding to the two letters used to start a program from the
  1491.         DESQview menu.
  1492.  
  1493.  
  1494.  
  1495.         7.5.2 How it Works
  1496.  
  1497.         CRONDV will use the DESQview API to spawn the corresponding programs
  1498.         asynchronously. The advantages are:
  1499.  
  1500.           -    CRONDV may run in a minimal (~ 40 K) window, since it doesn't
  1501.                spawn other processes in its own window
  1502.           -    for multiple-command CRONTAB entries, the commands will start
  1503.                simultaneously and run in parallel (in the DESQview sense)
  1504.           -    the xx-PIF.DVP files may be modified without the need to modify
  1505.                the CRONTAB
  1506.  
  1507.         The disadvantages are:
  1508.  
  1509.           -    CRONDV can *only* run xx-PIF.DVP files, *not* regular programs
  1510.           -    since CRONDV uses the "Sleep" API call, the real-time display is
  1511.                not available
  1512.           -    the CRONLOG will not (in fact, cannot) show return conditions of
  1513.                the spawned programs, since CRONDV doesn't wait for their return
  1514.  
  1515.  
  1516.  
  1517.         7.5.3 The CRONPIF Environment Variable
  1518.  
  1519.         CRONDV looks for an additional environment variable called CRONPIF. If
  1520.         present, any non-prefixed two-letter command is assumed to refer to an
  1521.         xx-PIF.DVP file in the directory named by CRONPIF. If CRONPIF is not
  1522.         set, CRONDV assumes C:\DV by default. For example, suppose you have
  1523.  
  1524.           SET CRONPIF=D:\MYPIFS
  1525.  
  1526.         then the CRONTAB entry
  1527.  
  1528.         2317   *    *    *    RE
  1529.  
  1530.         will make CRONDV try to execute D:\MYPIFS\RE-PIF.DVP at 17:23 daily,
  1531.         just as if you had entered RE under the Open Window option on the
  1532.         DESQview menu.
  1533.  
  1534.  
  1535.  
  1536.  
  1537.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  1538.  
  1539.  
  1540.  
  1541.  
  1542.         CRON User's Guide            Rev. 01-20-91                      Page 22
  1543.  
  1544.  
  1545.         On the other hand, the CRONTAB entry
  1546.  
  1547.         2317   *    *    *    d:\\specials\\re
  1548.  
  1549.         will execute D:\SPECIALS\RE-PIF.DVP regardless of the contents of
  1550.         CRONPIF.
  1551.  
  1552.  
  1553.  
  1554.         7.5.4 CRONLOG entries
  1555.  
  1556.         CRONDV only produces the '>' and '>>' flavours of CRONLOG entries,
  1557.         since it is not possible for CRONDV to detect when commands terminate.
  1558.  
  1559.  
  1560.  
  1561.         7.5.5 About Programs spawned by CRONDV
  1562.  
  1563.         CRONDV runs programs as if they were started by the two-letter
  1564.         sequences of the DESQview menu. This means that CRONDV does not control
  1565.         whether or not the programs close their window on exit. The
  1566.         xx-PIF.DVP's used with CRONDV should be set up with unattended
  1567.         execution in mind, so that you don't end up with lots of windows
  1568.         waiting for EXIT to be typed.
  1569.  
  1570.         CRONDV cannot control nor detect whether or not the programs could be
  1571.         started. Lack of memory, resource conflicts (e.g. two comm programs
  1572.         trying to use the same modem simultaneously) etc. goes undetected and
  1573.         unreported. It is your responsibility to make sure that these things do
  1574.         not cause trouble.
  1575.  
  1576.  
  1577.         7.5.6 Command-line Options
  1578.  
  1579.         CRONDV supports the following subset of the CRON command-line options:
  1580.  
  1581.           -c tab         -- CRONTAB override
  1582.           -n             -- no logfile
  1583.           -l             -- logfile locking for network logfiles
  1584.           -L             -- unconditional logfile locking
  1585.           -v             -- limited verbose mode
  1586.  
  1587.         See the corresponding section for CRON.EXE for further details.
  1588.  
  1589.         The -v option will make CRONDV print the name of the PIF file and the
  1590.         time of execution of the command each time CRONDV starts to wait for
  1591.         the next command to execute. There is no real-time display, so
  1592.         DVANSI.COM is not required.
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  1602.  
  1603.  
  1604.  
  1605.  
  1606.         CRON User's Guide            Rev. 01-20-91                      Page 23
  1607.  
  1608.  
  1609.         8 REFERENCE SECTION
  1610.  
  1611.  
  1612.  
  1613.         8.1 Error Messages
  1614.  
  1615.         CRON can complain about various things, at startup and later. All error
  1616.         output is sent to stdout (i.e. DOS handle 2). Any startup error, and
  1617.         some other errors, make CRON terminate.
  1618.  
  1619.         The following list describes the errors (in no particular order):
  1620.  
  1621.  
  1622.         cdd("dirname") failed
  1623.                CRON failed to do an internal drive/directory change. Usually
  1624.                means disk failure, or a spawned command has wreaked havoc in
  1625.                your system. This error can occur after each spawned command.
  1626.  
  1627.  
  1628.         No memory for crontab
  1629.                CRON failed to allocate dynamic memory for loading the crontab.
  1630.                This means that your crontab is *very* large or that you have
  1631.                very little memory in your system.
  1632.  
  1633.  
  1634.         'command' : illegal date
  1635.                The crontab entry containing 'command' specifies an illegal
  1636.                date, for example February 31. Correct the crontab entry.
  1637.  
  1638.  
  1639.         Syntax: 'entry'
  1640.                The crontab line containing 'entry' does not conform to crontab
  1641.                entry syntax rules. Correct the offending line.
  1642.  
  1643.  
  1644.         CRONTAB is empty
  1645.                No entries were found in crontab.
  1646.  
  1647.  
  1648.         'file': cannot open
  1649.                CRON could not open the named file. File probably does not
  1650.                exist.
  1651.  
  1652.  
  1653.         'name': not a directory
  1654.                The specified 'name' is not a directory (swap mode).
  1655.  
  1656.  
  1657.  
  1658.  
  1659.  
  1660.  
  1661.  
  1662.  
  1663.  
  1664.  
  1665.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  1666.  
  1667.  
  1668.  
  1669.  
  1670.         CRON User's Guide            Rev. 01-20-91                      Page 24
  1671.  
  1672.  
  1673.         Unable to locate CRONTAB
  1674.                Either the file name pointed to by the CRONTAB environment
  1675.                variable is invalid, or the file "CRONTAB" was not found in the
  1676.                startup directory.
  1677.  
  1678.  
  1679.         'CRONLOG=name' : not fully qualified
  1680.                The environment variable CRONLOG contains a name that is not a
  1681.                fully qualified filename.
  1682.  
  1683.  
  1684.         'CRONLOG=name' : cannot open
  1685.                CRON was unable to open the file named by the CRONLOG
  1686.                environment variable. Either the file exists and is read-only,
  1687.                or the name specifies a directory, or the network denied create
  1688.                or write access to the file.
  1689.  
  1690.  
  1691.         (DESQview detected)
  1692.                Not an error message, but a startup message stating that CRON
  1693.                believes that it is running under DESQview.
  1694.  
  1695.  
  1696.         DESQview not found
  1697.                CRONDV was started outside DESQview
  1698.  
  1699.  
  1700.         '[d:\path\]xx-PIF.DVP' : not found
  1701.                CRONDV did not find the specified .DVP file.
  1702.  
  1703.         Lock failure @ <timestamp>
  1704.                A lock() call on the logfile failed, either because locking is
  1705.                not supported and you used the -L option, or because the call
  1706.                timed out. CRON[dv] continues to run, but switches off logging
  1707.                and verbose mode, so that the message remains on the screen.
  1708.  
  1709.  
  1710.  
  1711.         8.2 Exit Codes
  1712.  
  1713.         Some exit codes (shown in the cronlog as 'rc = nn') have slightly
  1714.         different interpretations when running CRON in swap or non-swap mode.
  1715.  
  1716.  
  1717.  
  1718.         8.2.1 Common Exit Codes
  1719.  
  1720.         All exit codes in the range 0..255 are actual exit codes from spawned
  1721.         commands. Their interpretation is specific to each actual command. CRON
  1722.         does not attempt to interpret these codes except that in a multi-
  1723.         command entry, the remaining commands in the entry will be skipped if a
  1724.         command returns a non-0 exit code, as explained earlier.
  1725.  
  1726.  
  1727.  
  1728.  
  1729.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  1730.  
  1731.  
  1732.  
  1733.  
  1734.         CRON User's Guide            Rev. 01-20-91                      Page 25
  1735.  
  1736.  
  1737.         8.2.2 Swap Mode
  1738.  
  1739.         In swap mode, interpret exit codes as follows:
  1740.  
  1741.           -1        named command not found. Either the command is actually
  1742.                     non-existent, or you forgot to prefix a COMMAND.COM
  1743.                     internal command with '!'
  1744.  
  1745.           0..255    see 8.2.1
  1746.  
  1747.           256       swap file error. CRON switches swapping off permanently and
  1748.                     continues execution.
  1749.  
  1750.           770       DOS EXEC: file not found
  1751.           771       DOS EXEC: path not found
  1752.           772       DOS EXEC: too many open files
  1753.           773       DOS EXEC: access denied
  1754.           776       DOS EXEC: not enough memory to load command
  1755.           778       DOS EXEC: environment is corrupt
  1756.           779       DOS EXEC: bad format for .EXE file (.EXE file is corrupt)
  1757.  
  1758.  
  1759.  
  1760.         8.2.3 Non-Swap Mode
  1761.  
  1762.         In non-swap mode, interpret exit codes as follows:
  1763.  
  1764.           -1        spawn failure, errno gives further information
  1765.  
  1766.           0..255    see 8.2.1
  1767.  
  1768.         For -1, errno can take one of the following values:
  1769.  
  1770.            2        ENOENT:  path or file not found
  1771.            8        ENOMEM:  not enough memory to spawn command
  1772.           19        EINVAL:  illegal argument
  1773.           20        E2BIG:   argument list is too long
  1774.           21        ENOEXEC: .EXE file format error
  1775.  
  1776.  
  1777.  
  1778.         8.2.4 RC = -1 for '!' Commands
  1779.  
  1780.         If a command prefixed with '!' returns with 'rc = -1', it means that
  1781.         CRON was unable to spawn the command interpreter, i.e. the program
  1782.         named by the COMSPEC environment variable.
  1783.  
  1784.         This is a serious error. Some possible causes are:
  1785.  
  1786.           -    the COMSPEC environment variable has been corrupted
  1787.           -    the PATH has been corrupted
  1788.           -    the program named by COMSPEC (e.g. C:\COMMAND.COM) has
  1789.                disappeared. Look out for viruses.
  1790.           -    not enough memory to spawn command interpreter.
  1791.  
  1792.  
  1793.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  1794.  
  1795.  
  1796.  
  1797.  
  1798.         CRON User's Guide            Rev. 01-20-91                      Page 26
  1799.  
  1800.  
  1801.         9 UTILITY PROGRAMS
  1802.  
  1803.  
  1804.  
  1805.         9.1 CDD.EXE
  1806.  
  1807.         CDD (for "change drive and directory") is a smarter replacement for
  1808.         DOS's CHDIR (CD) command. Since CDD is an .EXE file, it will return an
  1809.         exit code != 0 if it was unable to switch drive and/or directory.
  1810.  
  1811.         USE: cdd [d:][\path]
  1812.  
  1813.         Exit codes:
  1814.  
  1815.           0    -- success
  1816.           1    -- could not switch drive
  1817.           2    -- could not change directory
  1818.           3    -- bad command line syntax
  1819.  
  1820.         CDD is small, so I recommend using the '~' command prefix when using
  1821.         CDD in crontabs.
  1822.  
  1823.         Typing "CDD ?" gives a command syntax reminder.
  1824.  
  1825.  
  1826.  
  1827.         9.2 LOGCHECK.EXE
  1828.  
  1829.         CRON usually produces large logfiles. To avoid excessive log sizes, put
  1830.         a call to LOGCHECK in your crontab, with a period depending on how much
  1831.         you use CRON and the execution frequency of your crontab entries.
  1832.  
  1833.         USE: logcheck [-s maxsize] [-L|-l]
  1834.  
  1835.         where 'maxsize' is the decimal number of kilobytes that you want your
  1836.         logfile not to exceed. If no 'maxsize' is entered, LOGCHECK assumes a
  1837.         value of 32. Use -L or -l if you want LOGCHECK to lock the logfile when
  1838.         it operates (similar to CRON's -L and -l options).
  1839.  
  1840.         If LOGCHECK finds that your current cronlog exceeds 'maxsize' it will
  1841.         perform the following actions:
  1842.  
  1843.           --   copy the current cronlog to a file with the same name but with
  1844.                extension 'old'. For example, if your cronlog is named
  1845.                'CRONLOG.CUR', its current contents will be copied to
  1846.                'CRONLOG.OLD'. If your cronlog is named 'CRONLOG.OLD', the copy
  1847.                will be named 'CRONLOG.OL2'. Any existing file with the modified
  1848.                name will be destroyed. The copy is made in the same directory
  1849.                as the cronlog.
  1850.  
  1851.           --   truncate the cronlog to 0 size, then add the following entry:
  1852.                '!logswap <timestamp>'.
  1853.  
  1854.  
  1855.  
  1856.  
  1857.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  1858.  
  1859.  
  1860.  
  1861.  
  1862.         CRON User's Guide            Rev. 01-20-91                      Page 27
  1863.  
  1864.  
  1865.         The following crontab entry will check your network cronlog daily,
  1866.         making sure it doesn't become much larger than 64K:
  1867.  
  1868.         13 5 * * * ~logcheck -s 64 -l
  1869.  
  1870.  
  1871.         Exit codes from LOGCHECK:
  1872.  
  1873.           0    -- successful log swap
  1874.           1    -- no action (log smaller than maxsize)
  1875.           2    -- could not swap log (disk error, access denied)
  1876.           3    -- CRONLOG environment variable not found.
  1877.           4    -- bad command line syntax
  1878.  
  1879.  
  1880.         Typing "LOGCHECK ?" gives a command syntax reminder.
  1881.  
  1882.         Caveat: LOGCHECK can only check the log when it is activated. Thus
  1883.         between invocations, the log can grow to a size much larger than
  1884.         'maxsize' if there is a lot of CRON activity going on. Select LOGCHECK 
  1885.         periodicity according to your crontab.
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  1922.  
  1923.  
  1924.  
  1925.  
  1926.         CRON User's Guide            Rev. 01-20-91                      Page 28
  1927.  
  1928.  
  1929.         10  PROGRAM HISTORY
  1930.  
  1931.  
  1932.  
  1933.         Version     Date      Comments
  1934.         -----------------------------------------------------------------------
  1935.         0.0 - 1.0   10-19-90  [Internal] Internal versions
  1936.         1.1         10-20-90  [Public] First public release
  1937.         1.2         10-21-90  [Internal] Benign bug fixed: in the absence of
  1938.                               the -L option, a file handle was needlessly kept
  1939.                               open permanently. Harmless, but wasteful. Also,
  1940.                               CRON.DOC stated that CRON would swap to the
  1941.                               current directory if no TMP variable and if no -d
  1942.                               option. This is wrong. CRON will swap to the
  1943.                               directory that was current when CRON started
  1944.                               under these conditions. LOGCHECK.EXE always
  1945.                               unlocked the logfile even if locking was not
  1946.                               specified.
  1947.         1.3         10-26-90  [Internal] Upgrade to T. Wagner's EXEC23 -- swap
  1948.                               file is now closed when spawning. Saves a file
  1949.                               handle.
  1950.         1.4         10-26-90  [Public] Added compile date to CRON's banner.
  1951.         1.5         01-15-91  [Internal] Added the character escape facility as
  1952.                               suggested by Julian Templeton.
  1953.         1.6         01-20-91  [Public] Now includes CRONDV.EXE, DESQview
  1954.                               specific version for spawning xx-PIF.DVP's. New
  1955.                               locking options, -l and -L, for finer control.
  1956.                               All .EXE's now have the same version number
  1957.                               (1.6).
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.         CRON User's Guide            Rev. 01-20-91        (C) 1991 Tron Hvaring
  1986.